<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#div1 {width:400px; height:300px; background:#CCC; display:none;}
</style>
<script>
window.onload=function ()
{
	var oBtn=document.getElementById('btn1');
	var oDiv=document.getElementById('div1');
	var isShow = false;
	
	oBtn.onclick=function (ev)
	{
		var oEvent=ev||event;
		
		//oDiv.style.display='block';
		isShow = !isShow;
		oDiv.style.display = isShow?'block':'none';
		//alert('按钮被点击了');
		
		oEvent.cancelBubble=true;
	};
	
	document.onclick=function ()
	{
		oDiv.style.display='none';
//		isShow = !isShow;
		isShow = false;
		//alert('document被点击了');
	};
};
</script>
</head>

<body>
<input id="btn1" type="button" value="显示" />
<div id="div1">
</div>
</body>
</html>
